home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cstdio.arc / SRC.ARC / FTELL.C < prev    next >
C/C++ Source or Header  |  1984-07-28  |  438b  |  21 lines

  1. /*    ftell.c - return current position of a stream.
  2.     (C) Copyright 1984 Gregory R. Mansfield - All Rights Reserved.
  3.     G. R. Mansfield.  84/07/26.
  4.     Ver 1.0-4726.
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. long ftell(fp) /* return current position of a stream */
  10. FILE *fp;
  11. {
  12.     long offset;
  13.  
  14.     offset = lseek(fp->_fd, 0L, 1);
  15.     if (fp->_flag & _READ)
  16.         offset -= (long)fp->_cnt;
  17.     else
  18.         offset += (long)(fp->_ptr - fp->_base);
  19.     return(offset);
  20. }
  21.